/// <summary>
/// This class handles requests from the API and 
/// sends them to the C# application via delegates.
/// <summary>

#include "InterProcess.h"

#pragma managed

namespace API
{
	InterProcess::InterProcess(void)
	{
		this->m_Manager = nullptr;
	}

	bool InterProcess::ApplicationIsInstalled(System::String ^ repository, System::String ^ application)
	{
		bool ret = this->m_ApplicationIsInstalled(this->m_Manager, repository, application);
		return ret;
	}

	bool InterProcess::ComponentIsInstalled(System::String ^ repository, System::String ^ application, System::String ^ component)
	{
		return this->m_ComponentIsInstalled(this->m_Manager, repository, application, component);
	}

	bool InterProcess::ComponentInstall(System::String ^ repository, System::String ^ application, System::String ^ component)
	{
		return this->m_ComponentInstall(this->m_Manager, repository, application, component);
	}

	bool InterProcess::ComponentUpdate(System::String ^ repository, System::String ^ application, System::String ^ component)
	{
		return this->m_ComponentUpdate(this->m_Manager, repository, application, component);
	}

	bool InterProcess::ComponentUninstall(System::String ^ repository, System::String ^ application, System::String ^ component)
	{
		return this->m_ComponentUninstall(this->m_Manager, repository, application, component);
	}

	bool InterProcess::VersionIsLatest(System::String ^ repository, System::String ^ application, System::String ^ component)
	{
		return this->m_VersionIsLatest(this->m_Manager, repository, application, component);
	}

	bool InterProcess::MiscellaneousCallURL(System::String ^ url)
	{
		return this->m_MiscellaneousCallURL(this->m_Manager, url);
	}

	bool InterProcess::AuthorizedCallURL(System::String ^ url)
	{
		return this->m_AuthorizedCallURL(this->m_Manager, url);
	}

	System::Object ^ InterProcess::InitializeLifetimeService()
	{
		return nullptr;
	}

	void InterProcess::SetCalls(
		DelegateB_SS  ^ applicationisinstalled,
		DelegateB_SSS ^ componentisinstalled,
		DelegateB_SSS ^ componentinstall,
		DelegateB_SSS ^ componentupdate,
		DelegateB_SSS ^ componentuninstall,
		DelegateB_SSS ^ versionislatest,
		DelegateB_S   ^ miscellaneouscallurl,
		DelegateB_S   ^ authorizedcallurl
		)
	{
		this->m_ApplicationIsInstalled = applicationisinstalled;
		this->m_ComponentIsInstalled = componentisinstalled;
		this->m_ComponentInstall = componentinstall;
		this->m_ComponentUpdate = componentupdate;
		this->m_ComponentUninstall = componentuninstall;
		this->m_VersionIsLatest = versionislatest;
		this->m_MiscellaneousCallURL = miscellaneouscallurl;
		this->m_AuthorizedCallURL = authorizedcallurl;
	}

	void InterProcess::SetManager(
		System::Object ^ manager)
	{
		this->m_Manager = manager;
	}

	System::String ^ InterProcess::GetHash()
	{
		return this->GetHashCode().ToString();
	}
}
